<?php
namespace Entities\Corp;

use Doctrine\ORM\Query;
use Doctrine\ORM\EntityRepository;

class CentroCustoRepository extends EntityRepository
{
	public function listar($params = array())
	{
		$qb		= $this->getEntityManager()->createQueryBuilder();
		$qb->select('cc')
		->from('Entities\Corp\CentroCusto', 'cc');

		$where	= $qb->expr()->andX();
		$where->add($qb->expr()->eq(1,1));
		foreach ($params as $key => $value)
		{
			$where->add($qb->expr()->eq($key, $value));

		}
		$qb->where($where)
		->orderBy('cc.ds_nome');

		return $this->getEntityManager()->createQuery($qb->getDQL());
	}

	public function listCombo()
	{
		$return	= array();
		$lista	= $this->listar()->getResult();
		foreach ($lista as $value)
		{
			$return[$value->getIdCentroCusto()]	= $value->getDsNome();
		}
		return $return;
	}
}